package com.miage.pki.form;

public class UserCreate {
    String username, password, passconfirm, last_name, first_name, country, organization, organizational_unit, email;
    
    public boolean isEmpty() {
        return username==null || last_name==null || first_name==null || password==null || passconfirm==null || country==null || organization==null || organizational_unit==null || email==null;
    }
    
    public boolean isComplete() {
        return !username.isEmpty() && !last_name.isEmpty() && !first_name.isEmpty() && !password.isEmpty() && !passconfirm.isEmpty() && !country.isEmpty() && !organization.isEmpty() && !organizational_unit.isEmpty() && !email.isEmpty();
    }
    
    public boolean hasSamePassword(){
        return password.equals(passconfirm);
    }
    
    public boolean okPassword(){
        return (password.matches("((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@!#$%]).{8,20})"));
    }
    
    public boolean okEmail(){
        return email.matches("^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@ [A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$");
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getPassconfirm() {
        return passconfirm;
    }

    public void setPassconfirm(String passconfirm) {
        this.passconfirm = passconfirm;
    }

    public String getLast_name() {
        return last_name;
    }

    public void setLast_name(String last_name) {
        this.last_name = last_name;
    }

    public String getFirst_name() {
        return first_name;
    }

    public void setFirst_name(String first_name) {
        this.first_name = first_name;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getOrganization() {
        return organization;
    }

    public void setOrganization(String organization) {
        this.organization = organization;
    }

    public String getOrganizational_unit() {
        return organizational_unit;
    }

    public void setOrganizational_unit(String organizational_unit) {
        this.organizational_unit = organizational_unit;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }
    
    
    
}
